<template>
  <span class="edu-icon">
    <svg class="icon svg-icon" aria-hidden="true" v-if="symbol" :style="fontSize">
      <use :xlink:href="iconClass"></use>
    </svg>
    <span class="icon iconfont" :class="iconClass" v-else :style="fontSize"></span>
  </span>
</template>

<script>
export default {
  name: 'Icon',
  props: {
    // 普通图标
    href: {
      type: String,
      required: true,
    },
    // 是否为svg图标
    symbol: {
      type: Boolean,
      default: false,
    },
    // 图标大小
    size: {
      type: String,
      default: '',
    },
  },
  computed: {
    iconClass() {
      return this.symbol ? `#${this.href}` : `${this.href}`;
    },
    fontSize() {
      if (!this.size) {
        return '';
      }
      return { fontSize: this.size };
    },
  },
};
</script>
